<template>
	<div class="container">
		<h3>授权管理</h3>
		<el-row style="margin-top: 20px">
		    <el-col :span="7">
		        <el-input placeholder="请输入关键词" v-model="searchName" style="width: 300px">
		            <i slot="prefix" class="el-input__icon el-icon-search"></i>
		            <el-button slot="append" @click="handleSearch">搜索</el-button>
		        </el-input>
		    </el-col>
		   <el-button type="primary" @click="goadd" style="float: right; margin-right: 10px">新增</el-button>
		</el-row>
		
		<el-table :data="tableData" border ref="multipleTable" header-cell-class-name="table-header" style="margin-top: 20px">
		    <el-table-column prop="accreditName" sortable label="授权名称"></el-table-column>
		    <el-table-column prop="accreditExpire" sortable label="授权截止时间"></el-table-column>
		    <el-table-column prop="companyNum" sortable label="授权企业数量"></el-table-column>
		    <el-table-column label="操作" width="150" align="center">
		        <template slot-scope="scope">
		
		            <el-button  type="text" style="color: #409EFF" @click="handleCheck(scope.row)">查看</el-button>
					<el-button  type="text" style="color: #409EFF" @click="handleEdit(scope.row)">编辑</el-button>
				
		        </template>
		    </el-table-column>
		</el-table>
		<el-pagination
		    layout="total, prev, pager, next, jumper"
		    :page-size="pagesize"
		    :current-page.sync="currentPage"
		    @current-change="handleCurrentChange"
		    :total="total"
		    style="margin-top: 20px"
		></el-pagination>
	</div>
</template>

<script>
	import { empower_inquire, empower_search } from "@/request/supervisionCenterApi.js"
	export default{
		data(){
			return{
				searchName:'',
				tableData:[],
				currentPage: 1,
				pagesize: 10,
				total: 0,
			}
		},
		mounted(){
			this.init()
		},
		methods:{
			init() {
				let data = {
					page: 1
				}
				empower_inquire(data).then((res) =>{
					this.tableData = res.rows
				})
			},
			// 跳转到编辑
			handleEdit(row){
				this.$router.push({
					path:'/supervisionCenter/warranty/edit',
					query: {
						id: row.id
					}
				})
			},
			
			// 跳转到查看
			handleCheck(row){
				this.$router.push({
					path:'/supervisionCenter/warranty/check',
					query: {
						id: row.id
					}
				})
			},
			
			// 跳转到新增
			goadd(){
				this.$router.push({
					path:'/supervisionCenter/warranty/added'
				})
			},
			
			// 搜索
			handleSearch(){
				let data = {
					accreditName: this.searchName
				}
				empower_search(data).then((res) =>{
					this.tableData = res.data
				})
			},
			//页数改变
			handleCurrentChange(){

			}
		}
	}
</script>

<style scoped>
	.el-pagination {
	    text-align: center;
	}
</style>
